<template>
    <div class="container">
        <div class="flex-box-align" style="padding-bottom: 20px;border-bottom: 1px solid #f4f4f4">
            <div class="flex">随访复诊</div>
        </div>

        <ul class="follow-info flex">
            <li>
                <span>姓名：</span>
                <span>{{name}}</span>
            </li>
            <li class="flex-box-align">
                <span>看诊地点：</span>
                <v-distpicker :province="province" :city="city" :area="district"
                              @province="selectProvince"
                              @city="selectCity"
                              @area="selectArea"
                ></v-distpicker>
            </li>
            <li class="flex-box-align">
                <span>看诊时间：</span>
                <el-date-picker
                        v-model="inquiryTime"
                        type="datetime"
                        placeholder="例：2018-02-01 13:00">
                </el-date-picker>
            </li>
            <li class="flex-box-align">
                <span>复诊情况：</span>
                <el-input type="textarea" autosize style="width: 200px" v-model="reviewSituation" placeholder="请输入"></el-input>
            </li>
            <li class="flex-box-align">
                <span>用药情况：</span>
                <el-input type="textarea" autosize style="width: 200px" v-model="useDrugSituation" placeholder="请输入"></el-input>
            </li>
        </ul>
        <div  style="margin-top: 40px;text-align: center;width:400px">
            <el-button type="primary" @click="handleClickSave">保存</el-button>
            <el-button type="primary" @click="$router.back(-1)">返回</el-button>
        </div>
    </div>
</template>

<script>
    let CONSTANT = require('../../constant/constant.js');
    let common = require("../../common.js");
    import {parseUrlParams} from "../../util";
    import VDistpicker from 'v-distpicker'

    export default {
        data() {
            return {
                showDetail: true,
                list: [],
                inquiryTime: "",
                reviewSituation: "",
                useDrugSituation: "",
                province: "",
                city: "",
                district: "",
                name: ""
            }
        },
        components: {
            VDistpicker
        },
        mounted() {
            this.name = decodeURI(parseUrlParams("name"))
        },
        methods: {
            selectProvince(val) {
                this.province = val.value
            },
            selectCity(val) {
                this.city = val.value
            },
            selectArea(val) {
                this.district = val.value
            },
            handleClickSave() {
                if (!this.province) {
                    this.$message.error('请选择省份');
                    return false
                }
                if (!this.city) {
                    this.$message.error('请选择城市');
                    return false
                }
                if (!this.district) {
                    this.$message.error('请选择地区');
                    return false
                }
                if (!this.inquiryTime) {
                    this.$message.error('请选择看诊时间');
                    return false
                }
                if (!this.reviewSituation) {
                    this.$message.error('请输入复诊情况');
                    return false
                }
                if (!this.useDrugSituation) {
                    this.$message.error('请输入用药情况');
                    return false
                }
                let params = {
                    patientId: parseUrlParams("id"),
                    province: this.province,
                    city: this.city,
                    district: this.district,
                    inquiryTime: this.inquiryTime,
                    reviewSituation: this.reviewSituation,
                    useDrugSituation: this.useDrugSituation,
                }
                common.requestAjax(CONSTANT.URL.PATIENT.FOLLOWEDIT, JSON.stringify(params), {}, (res) => {
                    if (res.status == 200) {
                        this.$message({
                            message: res.msg,
                            type: 'success'
                        });
                        this.$router.back(-1)
                    }

                })
            }
        }
    }
</script>

<style lang="scss">
    .container {
        .follow-info {
            li {
                margin-top: 20px;
            }
            li>span:nth-child(1) {
                display: inline-block;
                width: 200px;
            }
        }


    }
</style>
